package com.androidx.p013lv.mine.dialog;

import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.androidx.p013lv.base.utils.UiUtils;
import com.androidx.p013lv.mine.C1207R;

/* renamed from: com.androidx.lv.mine.dialog.FastDialogUtils */
public class FastDialogUtils {
    private static FastDialogUtils mFastDialogUtils;
    private PopupWindow mServicePopupWindow;

    public static FastDialogUtils getInstance() {
        if (mFastDialogUtils == null) {
            mFastDialogUtils = new FastDialogUtils();
        }
        return mFastDialogUtils;
    }

    public void createServicePopupWindow(Activity activity, View view, String str, String str2, View.OnClickListener onClickListener, View.OnClickListener onClickListener2) {
        if (this.mServicePopupWindow == null) {
            initServicePopupWindow(activity, str, str2, onClickListener, onClickListener2);
        }
        if (!this.mServicePopupWindow.isShowing()) {
            this.mServicePopupWindow.showAsDropDown(view, 0, -UiUtils.dp2px(25));
            return;
        }
        this.mServicePopupWindow.dismiss();
        this.mServicePopupWindow = null;
    }

    private void initServicePopupWindow(final Activity activity, String str, String str2, final View.OnClickListener onClickListener, final View.OnClickListener onClickListener2) {
        View inflate = ((LayoutInflater) activity.getSystemService("layout_inflater")).inflate(C1207R.C1212layout.custom_service_select_layout, (ViewGroup) null);
        PopupWindow popupWindow = new PopupWindow(inflate, -2, -2);
        this.mServicePopupWindow = popupWindow;
        popupWindow.setAnimationStyle(C1207R.C1214style.pop_add);
        this.mServicePopupWindow.setFocusable(true);
        this.mServicePopupWindow.setBackgroundDrawable(new BitmapDrawable());
        this.mServicePopupWindow.setOutsideTouchable(true);
        this.mServicePopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            /* class com.androidx.p013lv.mine.dialog.FastDialogUtils.C12981 */

            public void onDismiss() {
                WindowManager.LayoutParams attributes = activity.getWindow().getAttributes();
                attributes.alpha = 1.0f;
                activity.getWindow().setAttributes(attributes);
                FastDialogUtils.this.mServicePopupWindow = null;
            }
        });
        if (!TextUtils.isEmpty(str)) {
            ((TextView) inflate.findViewById(C1207R.C1210id.tv1)).setText(str);
        } else {
            inflate.findViewById(C1207R.C1210id.ll_01).setVisibility(8);
        }
        if (!TextUtils.isEmpty(str2)) {
            ((TextView) inflate.findViewById(C1207R.C1210id.tv2)).setText(str2);
        } else {
            inflate.findViewById(C1207R.C1210id.ll_02).setVisibility(8);
        }
        inflate.findViewById(C1207R.C1210id.ll_01).setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.mine.dialog.FastDialogUtils.View$OnClickListenerC12992 */

            public void onClick(View view) {
                new Handler().postDelayed(new Runnable() {
                    /* class com.androidx.p013lv.mine.dialog.FastDialogUtils.View$OnClickListenerC12992.RunnableC13001 */

                    public void run() {
                        if (onClickListener != null) {
                            onClickListener.onClick(null);
                        }
                        if (FastDialogUtils.this.mServicePopupWindow != null) {
                            FastDialogUtils.this.mServicePopupWindow.dismiss();
                            FastDialogUtils.this.mServicePopupWindow = null;
                        }
                    }
                }, 250);
            }
        });
        inflate.findViewById(C1207R.C1210id.ll_02).setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.mine.dialog.FastDialogUtils.View$OnClickListenerC13013 */

            public void onClick(View view) {
                new Handler().postDelayed(new Runnable() {
                    /* class com.androidx.p013lv.mine.dialog.FastDialogUtils.View$OnClickListenerC13013.RunnableC13021 */

                    public void run() {
                        if (onClickListener2 != null) {
                            onClickListener2.onClick(null);
                        }
                        if (FastDialogUtils.this.mServicePopupWindow != null) {
                            FastDialogUtils.this.mServicePopupWindow.dismiss();
                            FastDialogUtils.this.mServicePopupWindow = null;
                        }
                    }
                }, 250);
            }
        });
    }
}
